package com.ruoyi.dispatch.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dispatch.domain.MineInformation;
import com.ruoyi.dispatch.service.IMineInformationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 矿井基础信息Controller
 * 
 * @author wuxiaofang
 * @date 2025-04-01
 */
@RestController
@RequestMapping("/dispatch/information")
@Anonymous
public class MineInformationController extends BaseController
{
    @Autowired
    private IMineInformationService mineInformationService;

    /**
     * 查询矿井基础信息列表
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:information:list')")
    @GetMapping("/list")
    public TableDataInfo list(MineInformation mineInformation)
    {
        startPage();
        List<MineInformation> list = mineInformationService.selectMineInformationList(mineInformation);
        return getDataTable(list);
    }

    /**
     * 导出矿井基础信息列表
     */
   // @PreAuthorize("@ss.hasPermi('dispatch:information:export')")
    @Log(title = "矿井基础信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MineInformation mineInformation)
    {
        List<MineInformation> list = mineInformationService.selectMineInformationList(mineInformation);
        ExcelUtil<MineInformation> util = new ExcelUtil<MineInformation>(MineInformation.class);
        util.exportExcel(response, list, "矿井基础信息数据");
    }

    /**
     * 获取矿井基础信息详细信息
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:information:query')")
    @GetMapping(value = "/{mineInfoId}")
    public AjaxResult getInfo(@PathVariable("mineInfoId") Long mineInfoId)
    {
        return success(mineInformationService.selectMineInformationByMineInfoId(mineInfoId));
    }

    /**
     * 新增矿井基础信息
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:information:add')")
    @Log(title = "矿井基础信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MineInformation mineInformation)
    {
        mineInformation.setCreateBy(getUsername());
        return toAjax(mineInformationService.insertMineInformation(mineInformation));
    }

    /**
     * 修改矿井基础信息
     */
   // @PreAuthorize("@ss.hasPermi('dispatch:information:edit')")
    @Log(title = "矿井基础信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MineInformation mineInformation)
    {
        mineInformation.setUpdateBy(getUsername());
        return toAjax(mineInformationService.updateMineInformation(mineInformation));
    }

    /**
     * 删除矿井基础信息
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:information:remove')")
    @Log(title = "矿井基础信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{mineInfoIds}")
    public AjaxResult remove(@PathVariable Long[] mineInfoIds)
    {
        return toAjax(mineInformationService.deleteMineInformationByMineInfoIds(mineInfoIds));
    }
}
